package oop2.exer2;

/**
 * Created with IntelliJ IDEA.
 * ClassName: Account
 * Package: oop2.exer2
 * Description:
 * User: fzykd
 *
 * @Author: LQH
 * Date: 2023-11-21
 * Time: 15:43
 */

//账户类
public class Account {
    private double balance;

    public Account(double init_balance) {
        this.balance = init_balance;
    }

    public double getBalance() {
        return balance;
    }

    //存钱
    public void deposit(double amt) {
        if (amt > 0) {
            balance += amt;
            System.out.println("成功存入" + amt);
        }
    }

    //取钱
    public void withdraw(double amt) {
        if (balance >= amt && amt > 0) {
            balance -= amt;
            System.out.println("成功取钱" + amt);
        } else {
            System.out.println("余额不足");
        }
    }

}
